﻿namespace FilteredPageReference.UserControls
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using EPiServer;
    using EPiServer.ClientScript.WebControls;
    using EPiServer.Configuration;
    using EPiServer.Core;
    using EPiServer.DataAbstraction;
    using EPiServer.Globalization;
    using EPiServer.Personalization;
    using EPiServer.Security;
    using EPiServer.Shell.Web;
    using EPiServer.UI;
    using EPiServer.UI.WebControls;
    using EPiServer.Web;
    using EPiServer.Web.PageExtensions;
    using EPiServer.Web.WebControls;

    public class PageExplorerFilteredPageReference : UserControl
    {
        // Fields
        private static SortedList<PageReference, string> _configuredStartPages;
        private Hashtable _languageBranchLookup;
        private static object _lockObject = new object();
        private Hashtable _translateCache = new Hashtable();
        private GuiSettings _treeSettings;
        protected Literal noFavouritesMessage;
        protected Panel noFavouritesPanel;
        protected ScriptSettings toolTip;
        protected PageTreeView treeView;

        private PropertyFilteredPageReferenceSettings _settings;

        protected string FPRData
        {
            get
            {
                return Server.UrlDecode(Request.QueryString["fprdata"]);
            }
        }

        protected string FPRKey
        {
            get { return Request.QueryString["fprkey"]; }
        }

        protected PropertyFilteredPageReferenceSettings FPRSettings
        {
            get
            {
                if (_settings == null)
                    _settings = Helper.GetPropertySettings(FPRData, FPRKey);

                return _settings;
            }
        }

        private void AppendLanguageIcon(PageRenderContext context, Control containerControl)
        {
            if ((Settings.Instance.UIShowGlobalizationUserInterface && (this.TreeSettings.ShowLanguageMissing || this.TreeSettings.ShowLanguageFallback)) && (((context.Page.PageLink != PageReference.RootPage) && !DataFactory.Instance.IsWastebasket(context.Page.PageLink)) && !string.Equals(context.Page.LanguageBranch, ContentLanguage.PreferredCulture.Name, StringComparison.OrdinalIgnoreCase)))
            {
                if (!context.UsingFallbackLanguage && this.TreeSettings.ShowLanguageMissing)
                {
                    containerControl.Controls.Add(CreateStatusImage("LanguageMissing.gif", this.InternalTranslate("/webcontrols/explorertree/statuslanguagemissing")));
                }
                if (context.UsingFallbackLanguage && this.TreeSettings.ShowLanguageFallback)
                {
                    LanguageBranch branch = this.LanguageBranchLookup[context.Page.LanguageBranch] as LanguageBranch;
                    Image child = new ThemeImage();
                    child.CssClass = "statusicon";
                    child.Style.Add(HtmlTextWriterStyle.Height, "11px");
                    child.ToolTip = this.InternalTranslate("/webcontrols/explorertree/statuslanguagefallback");
                    if (branch != null)
                    {
                        child.ToolTip = child.ToolTip + " (" + branch.Name + ")";
                    }
                    if ((branch != null) && !string.IsNullOrEmpty(branch.SystemIconPath))
                    {
                        child.ImageUrl = branch.SystemIconPath;
                    }
                    else
                    {
                        child.ImageUrl = ThemeUtility.GetImageThemeUrl(this.Page, "ExplorerTree/PageTree/LanguageMissing.gif");
                    }
                    child.AlternateText = child.ToolTip;
                    containerControl.Controls.Add(child);
                }
            }
        }

        private void AppendPublishStatusIcon(PageData page, Control containerControl)
        {
            if (!page.CheckPublishedStatus(PagePublishedStatus.Published))
            {
                string str = null;
                string title = null;
                if ((this.TreeSettings.ShowExpired && page.CheckPublishedStatus(PagePublishedStatus.PublishedIgnoreStopPublish)) && (page.StopPublish < DateTime.Now))
                {
                    str = "PublishExpired.gif";
                    title = string.Format(this.InternalTranslate("/webcontrols/explorertree/statusexpired"), page.Property["PageStopPublish"].ToString());
                }
                else if ((this.TreeSettings.ShowNotStarted && page.CheckPublishedStatus(PagePublishedStatus.PublishedIgnoreDates)) && (page.StartPublish > DateTime.Now))
                {
                    str = "AwaitingPublish.gif";
                    title = string.Format(this.InternalTranslate("/webcontrols/explorertree/statusnotstarted"), page.Property["PageStartPublish"].ToString());
                }
                else if (this.TreeSettings.ShowNotPublished)
                {
                    str = "Unpublished.gif";
                    title = this.InternalTranslate("/webcontrols/explorertree/statusnotpublished");
                }
                if (!string.IsNullOrEmpty(str))
                {
                    containerControl.Controls.Add(CreateStatusImage(str, title));
                }
            }
        }

        private void AppendRootLevelSettings(PageTreeNode treeNode)
        {
            PageData dataItem = treeNode.DataItem as PageData;
            string imageUrl = string.Empty;
            if (treeNode.Depth == 0)
            {
                if (this.DisplayTreeMode == TreeMode.FavouritesTree)
                {
                    imageUrl = "ExplorerTree/favorite.gif";
                }
                else if (PageReference.RootPage.CompareToIgnoreWorkID(dataItem.PageLink))
                {
                    imageUrl = "ExplorerTree/PageTree/Root.gif";
                    treeNode.Expand();
                }
            }
            else if (PageReference.WasteBasket.CompareToIgnoreWorkID(dataItem.PageLink))
            {
                if (treeNode.HasChildren)
                {
                    imageUrl = "ExplorerTree/PageTree/FullWasteBasket.gif";
                }
                else
                {
                    imageUrl = "ExplorerTree/PageTree/WasteBasket.gif";
                }
            }
            else if (ConfiguredStartPages.ContainsKey(dataItem.PageLink))
            {
                imageUrl = "ExplorerTree/PageTree/StartPage.gif";
                if (PageReference.StartPage.CompareToIgnoreWorkID(dataItem.PageLink))
                {
                    treeNode.Expand();
                }
                else
                {
                    Settings settings = Settings.All[ConfiguredStartPages[dataItem.PageLink]];
                    string absoluteUri = UriSupport.Combine(settings.SiteUrl, settings.UIUrl).AbsoluteUri;
                    treeNode.Attributes.Add("HostUIUrl", absoluteUri);
                }
            }
            if (dataItem.PageLink.IsRemote() && DataFactory.Instance.IsWastebasket(dataItem.PageLink))
            {
                if (treeNode.HasChildren)
                {
                    imageUrl = "ExplorerTree/PageTree/FullWasteBasket.gif";
                }
                else
                {
                    imageUrl = "ExplorerTree/PageTree/WasteBasket.gif";
                }
            }
            if (imageUrl.Length > 0)
            {
                ThemeImage child = new ThemeImage(imageUrl);
                child.CssClass = "typeicon";
                treeNode.TemplateContainer.Controls.AddAt(0, child);
            }
        }

        protected void AppendStatusIcons(PageRenderContext context, Control containerControl)
        {
            string name = ContentLanguage.PreferredCulture.Name;
            Label child = new Label();
            child.CssClass = "iconcontainer";
            containerControl.Controls.Add(child);
            PageData page = context.Page;
            this.AppendLanguageIcon(context, child);
            this.AppendPublishStatusIcon(page, child);
            if (this.TreeSettings.ShowNotVisibleInMenu && !page.VisibleInMenu)
            {
                child.Controls.Add(CreateStatusImage("HiddenInMenu.gif", this.InternalTranslate("/webcontrols/explorertree/statusnotvisibleinmenu")));
            }
            if (this.TreeSettings.ShowReadOnly && (page.QueryAccess() <= AccessLevel.Read))
            {
                child.Controls.Add(CreateStatusImage("Access.gif", this.InternalTranslate("/webcontrols/explorertree/statusreadonly")));
            }
            if (this.TreeSettings.ShowNew && (page.Created.AddDays(2.0) > DateTime.Now))
            {
                child.Controls.Add(CreateStatusImage("NewPage.gif", this.InternalTranslate("/webcontrols/explorertree/statusnew")));
            }
            if (this.TreeSettings.ShowPageProviderIcon && page.PageLink.IsRemote())
            {
                PageProviderBase pageProvider = DataFactory.Instance.ProviderMap.GetPageProvider(page.PageLink);
                if (!string.IsNullOrEmpty(pageProvider.IconPath) && (page.PageLink != pageProvider.WastebasketReference))
                {
                    child.Controls.Add(CreateStatusImage(pageProvider.IconPath, this.InternalTranslate("/webcontrols/explorertree/statusnotlocal")));
                }
            }
            if (page.LinkType != PageShortcutType.Normal)
            {
                string additionalInformation = this.GetAdditionalInformation(page);
                if (this.TreeSettings.ShowShortcutIcon && (page.LinkType == PageShortcutType.Shortcut))
                {
                    child.Controls.Add(CreateStatusImage("Shortcut.gif", additionalInformation));
                }
                if (this.TreeSettings.ShowExternalIcon && (page.LinkType == PageShortcutType.External))
                {
                    child.Controls.Add(CreateStatusImage("External.gif", additionalInformation));
                }
                if (this.TreeSettings.ShowInactiveIcon && (page.LinkType == PageShortcutType.Inactive))
                {
                    child.Controls.Add(CreateStatusImage("Inactive.png", additionalInformation));
                }
                if (this.TreeSettings.ShowFetchDataIcon && (page.LinkType == PageShortcutType.FetchData))
                {
                    child.Controls.Add(CreateStatusImage("FetchData.png", additionalInformation));
                }
            }
        }

        protected PageDataSource CreateDataSource(TreeMode treeMode)
        {
            PageDataSource source = null;

            source = this.DisplayTreeMode == TreeMode.ExplorerTree ? new PageDataSource() : new FavouritesDataSource();

            PageReference startPage = Helper.GetPagePickingStartPage(FPRSettings, FPRData);

            if (!PageReference.IsNullOrEmpty(startPage))
                source.PageLink = startPage;

            source.EvaluateHasChildren = !Settings.Instance.UIOptimizeTreeForSpeed;
            source.EnableVisibleInMenu = false;
            source.IncludeRootPage = true;
            source.UseFallbackLanguage = true;
            source.PublishedStatus = PagePublishedStatus.Ignore;
            return source;
        }

        private static Image CreateStatusImage(string imageName, string title)
        {
            ThemeImage image = new ThemeImage("ExplorerTree/PageTree/" + imageName);
            image.ToolTip = image.AlternateText = title;
            image.CssClass = "statusicon";
            return image;
        }

        protected override void DataBindChildren()
        {
            this.treeView.DataBind();
        }

        private string GetAdditionalInformation(PageData page)
        {
            if (page.LinkType == PageShortcutType.Shortcut)
            {
                return string.Format(this.InternalTranslate("/webcontrols/explorertree/statusshortcutformat"), this.GetShortcutLinkName(page));
            }
            if (page.LinkType == PageShortcutType.External)
            {
                return string.Format(this.InternalTranslate("/webcontrols/explorertree/statusexternalformat"), page.LinkURL.Ellipsis(50));
            }
            if (page.LinkType == PageShortcutType.Inactive)
            {
                return this.InternalTranslate("/webcontrols/explorertree/statusinactive");
            }
            if (page.LinkType == PageShortcutType.FetchData)
            {
                return string.Format(this.InternalTranslate("/webcontrols/explorertree/statusfetchdataformat"), this.GetShortcutLinkName(page));
            }
            return "";
        }

        private string GetShortcutLinkName(PageData page)
        {
            PageReference pageLink = page["PageShortcutLink"] as PageReference;
            if (!PageReference.IsNullOrEmpty(pageLink))
            {
                try
                {
                    PageData data = DataFactory.Instance.GetPage(pageLink);
                    string str = data.PageName.Ellipsis(50);
                    return string.Format("{0} [{1}]", str, data.PageLink);
                }
                catch (PageNotFoundException)
                {
                }
            }
            return null;
        }

        private string InternalTranslate(string key)
        {
            return this.InternalTranslate(key, string.Empty);
        }

        private string InternalTranslate(string key, string fallback)
        {
            string str;
            if (this._translateCache.Contains(key))
            {
                return this._translateCache[key].ToString();
            }
            if (string.IsNullOrEmpty(fallback))
            {
                str = LanguageManager.Instance.Translate(key);
            }
            else
            {
                str = LanguageManager.Instance.TranslateFallback(key, fallback);
            }
            this._translateCache.Add(key, str);
            return str;
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            PageBase page = this.Page as PageBase;
            if (page == null)
            {
                throw new EPiServerException("The control EPiServer.UI.Edit.PageExplorer must be placed on a page inheriting from EPiServer.PageBase");
            }
            page.RegisterClientScriptFile(page.ResolveUrlFromUI("javascript/epitooltip.js"));
            if (!this.Page.ClientScript.IsClientScriptBlockRegistered(base.GetType(), "_pageExplorerInit"))
            {
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("function _pageExplorerInit(treeView) {");
                builder.AppendLine("    treeView.OnNodeOver = EPi.ToolTip.Show;");
                if (!string.IsNullOrEmpty(this.ClientInitializationCallback))
                {
                    builder.AppendLine("    " + this.ClientInitializationCallback + "(treeView);");
                }
                builder.AppendLine("}");
                this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "_pageExplorerInit", builder.ToString(), true);
            }
            if (this.treeView.DataSource == null)
            {
                this.treeView.DataSource = this.CreateDataSource(this.DisplayTreeMode);
            }
            if (this.Visible && !this.Page.IsCallback)
            {
                this.treeView.DataBind();
            }
        }

        protected void PageTreeView_ItemDataBound(object sender, PageTreeViewEventArgs e)
        {
            PageData dataItem = e.Item.DataItem as PageData;
            PageProviderBase pageProvider = DataFactory.Instance.GetPageProvider(dataItem.PageLink);
            bool isWasteBasket = DataFactory.Instance.IsWastebasket(dataItem.PageLink);
            int num = this.SetACL(dataItem, isWasteBasket);
            if (!PageLanguageSettingsTree.Instance.IsLanguageAllowedForCreation(dataItem.PageLink, ContentLanguage.PreferredCulture.Name))
            {
                num &= -7;
            }
            int capabilities = (int)pageProvider.Capabilities;
            if (DataFactory.Instance.ProviderMap.IsEntryPoint(dataItem.PageLink))
            {
                PageProviderBase base3 = DataFactory.Instance.ProviderMap.GetPageProvider(dataItem.PageLink);
                if (!base3.HasCapability(PageProviderCapabilities.Create))
                {
                    capabilities &= -2;
                }
                if (!base3.HasCapability(PageProviderCapabilities.Copy))
                {
                    capabilities &= -17;
                }
                if (!base3.HasCapability(PageProviderCapabilities.Move))
                {
                    capabilities &= -9;
                }
            }
            this.AppendRootLevelSettings(e.Item);
            PageRenderContext context = new PageRenderContext(dataItem);
            this.RenderAnchor(context, e.Item.TemplateContainer);
            this.AppendStatusIcons(context, e.Item.TemplateContainer);
            e.Item.Attributes.Add("commonScriptObject", this.toolTip.ClientID);
            e.Item.Attributes.Add("PageTypeName", this.InternalTranslate("/pagetypes/pagetype[@name='" + dataItem.PageTypeName + "']/name", dataItem.PageTypeName));
            e.Item.Attributes.Add("PagePeerOrder", dataItem.Property["PagePeerOrder"].ToString());
            e.Item.Attributes.Add("ACL", num.ToString());
            e.Item.Attributes.Add("Capabilities", capabilities.ToString());
            e.Item.Attributes.Add("IsWastebasket", isWasteBasket ? "true" : "false");
            e.Item.Attributes.Add("IsDeleted", dataItem.IsDeleted.ToString().ToLowerInvariant());
            string additionalInformation = this.GetAdditionalInformation(dataItem);
            if (!string.IsNullOrEmpty(additionalInformation))
            {
                additionalInformation = "<br />" + base.Server.HtmlEncode(additionalInformation).Replace("[", "&#91;").Replace("]", "&#93;");
            }
            e.Item.Attributes.Add("AdditionalInformation", additionalInformation);
        }

        private void RenderAnchor(PageRenderContext context, Control container)
        {
            HtmlAnchor child = new HtmlAnchor();
            string linkURL = context.Page.LinkURL;
            if (this.Page.IsCallback && UrlRewriteProvider.IsFurlEnabled)
            {
                UrlBuilder url = null;
                try
                {
                    url = new UrlBuilder(linkURL);
                }
                catch (UriFormatException)
                {
                }
                if (url != null)
                {
                    Global.UrlRewriteProvider.ConvertToExternal(url, null, Encoding.UTF8);
                    linkURL = url.ToString();
                }
            }
            child.HRef = linkURL;
            child.Target = "PreviewFrame";
            string str2 = context.Page.PageName.Trim();
            if (string.IsNullOrEmpty(str2))
            {
                str2 = string.Format("[{0}]", context.Page.PageLink);
            }
            if (context.Page.PageLink.CompareToIgnoreWorkID(PageReference.RootPage))
            {
                child.InnerHtml = base.Server.HtmlEncode(LanguageManager.Instance.Translate("/admin/settings/epsrootdircaption"));
            }
            else if (context.Page.PageLink == PageReference.WasteBasket)
            {
                child.InnerHtml = base.Server.HtmlEncode(LanguageManager.Instance.Translate("/edit/wastebasketpage/heading"));
            }
            else if (RenderCursive(context))
            {
                child.InnerHtml = "<em>" + base.Server.HtmlEncode(str2) + "</em>";
            }
            else
            {
                child.InnerHtml = base.Server.HtmlEncode(str2);
            }

            // Additional code to reflected version added by Lee Crowe - Start
            bool added = false;
            bool valid = false;

            if (!Helper.IsValidPageType(context.Page.PageTypeID, FPRSettings, Helper.GetPropertyInformation(FPRData, ref valid)))
            {
                child.Disabled = true;
                HtmlGenericControl tempItem = new HtmlGenericControl("span");

                if (context.Page.PageLink.CompareToIgnoreWorkID(PageReference.RootPage))
                    tempItem.InnerHtml = "&nbsp;" + Server.HtmlEncode(LanguageManager.Instance.Translate("/admin/settings/epsrootdircaption"));
                else if (context.Page.PageLink == PageReference.WasteBasket)
                    tempItem.InnerHtml = "&nbsp;" + Server.HtmlEncode(LanguageManager.Instance.Translate("/edit/wastebasketpage/heading"));
                else if (RenderCursive(context))
                    tempItem.InnerHtml = "<em>&nbsp;" + Server.HtmlEncode(str2) + "</em>";
                else
                    tempItem.InnerHtml = "&nbsp;" + Server.HtmlEncode(str2);

                if (!tempItem.InnerHtml.StartsWith("<em>"))
                    tempItem.InnerHtml = string.Concat("<em>", tempItem.InnerHtml, "</em>");

                container.Controls.Add(tempItem);
                added = true;
            }

            if (!added) // Additional code to reflected version added by Lee Crowe - End
                container.Controls.Add(child);

        }

        private static bool RenderCursive(PageRenderContext context)
        {
            if (!Settings.Instance.UIShowGlobalizationUserInterface)
            {
                return false;
            }
            if (string.Compare(context.Page.LanguageBranch, ContentLanguage.PreferredCulture.Name, true) == 0)
            {
                return false;
            }
            if (context.UsingFallbackLanguage)
            {
                return false;
            }
            return true;
        }

        private int SetACL(PageData pageData, bool isWasteBasket)
        {
            int accessLevel;
            if (pageData.IsDeleted)
            {
                accessLevel = (int)DataFactory.Instance.GetPage(PageReference.WasteBasket).GetSecurityDescriptor().GetAccessLevel(PrincipalInfo.CurrentPrincipal);
            }
            else
            {
                accessLevel = (int)pageData.GetSecurityDescriptor().GetAccessLevel(PrincipalInfo.CurrentPrincipal);
            }
            if (isWasteBasket)
            {
                accessLevel &= -3;
            }
            return accessLevel;
        }

        protected void TreeView_DataBound(object sender, EventArgs e)
        {
            if ((this.DisplayTreeMode == TreeMode.FavouritesTree) && (this.treeView.Nodes.Count == 0))
            {
                this.noFavouritesPanel.Visible = true;
                this.treeView.Visible = false;
            }
            else
            {
                this.noFavouritesPanel.Visible = false;
                this.treeView.Visible = true;
            }
        }

        // Properties
        [Localizable(false), DefaultValue(""), Category("Behaviour")]
        public string ClientInitializationCallback
        {
            get
            {
                return (this.ViewState["ClientInitializationCallback"] == null ? string.Empty : this.ViewState["ClientInitializationCallback"].ToString());
            }
            set
            {
                this.ViewState["ClientInitializationCallback"] = value;
            }
        }

        private static SortedList<PageReference, string> ConfiguredStartPages
        {
            get
            {
                lock (_lockObject)
                {
                    if (_configuredStartPages == null)
                    {
                        _configuredStartPages = new SortedList<PageReference, string>();
                        foreach (KeyValuePair<string, Settings> pair in Settings.All)
                        {
                            PageReference key = new PageReference(pair.Value.PageStartId);
                            _configuredStartPages.Add(key, pair.Key);
                        }
                    }
                    return _configuredStartPages;
                }
            }
        }

        [Localizable(true), Category("Appearance"), DefaultValue("ExplorerTree")]
        public TreeMode DisplayTreeMode
        {
            get
            {
                return (TreeMode)Enum.Parse(typeof(TreeMode), this.ViewState["TreeMode"] == null ? "ExplorerTree" : ViewState["TreeMode"].ToString());
            }
            set
            {
                this.ViewState["TreeMode"] = value.ToString();
            }
        }

        [Category("Behaviour"), DefaultValue(false), Localizable(false)]
        public bool EnableDragAndDrop
        {
            get
            {
                return this.treeView.EnableDragAndDrop;
            }
            set
            {
                this.treeView.EnableDragAndDrop = value;
            }
        }

        [DefaultValue(false), Category("Behaviour"), Localizable(false)]
        public bool EnableDropBetweenNodes
        {
            get
            {
                return this.treeView.EnableDropBetweenNodes;
            }
            set
            {
                this.treeView.EnableDropBetweenNodes = value;
            }
        }

        public int ExpandDepth
        {
            get
            {
                return this.treeView.ExpandDepth;
            }
            set
            {
                this.treeView.ExpandDepth = value;
            }
        }

        public bool ExpandOnSelect
        {
            get
            {
                return this.treeView.ExpandOnSelect;
            }
            set
            {
                this.treeView.ExpandOnSelect = value;
            }
        }

        private Hashtable LanguageBranchLookup
        {
            get
            {
                if (this._languageBranchLookup == null)
                {
                    LanguageBranchCollection branchs = LanguageBranch.ListAll();
                    this._languageBranchLookup = new Hashtable(branchs.Count);
                    foreach (LanguageBranch branch in branchs)
                    {
                        this._languageBranchLookup.Add(branch.LanguageID, branch);
                    }
                }
                return this._languageBranchLookup;
            }
        }

        public string SelectedNodeViewPath
        {
            get
            {
                return this.treeView.SelectedNodeViewPath;
            }
            set
            {
                this.treeView.SelectedNodeViewPath = value;
            }
        }

        protected GuiSettings TreeSettings
        {
            get
            {
                if (this._treeSettings == null)
                {
                    if (EPiServerProfile.Enabled)
                    {
                        this._treeSettings = EPiServerProfile.Current.EditTreeSettings;
                    }
                    else
                    {
                        this._treeSettings = new GuiSettings();
                        this._treeSettings.SettingsEnabled = false;
                    }
                }
                return this._treeSettings;
            }
        }

        // Nested Types
        [StructLayout(LayoutKind.Sequential)]
        protected struct PageRenderContext
        {
            private PageData _page;
            private bool? _usingFallbackLanguage;
            public PageRenderContext(PageData page)
            {
                this._page = page;
                this._usingFallbackLanguage = null;
            }

            public PageData Page
            {
                get
                {
                    return this._page;
                }
            }
            public bool UsingFallbackLanguage
            {
                get
                {
                    if (!this._usingFallbackLanguage.HasValue)
                    {
                        this._usingFallbackLanguage = new bool?(SystemPageBase.IsPageFallbackLanguageDefined(this.Page.PageLink, ContentLanguage.PreferredCulture.Name, this.Page.LanguageBranch));
                    }
                    return this._usingFallbackLanguage.Value;
                }
            }
        }

        public enum TreeMode
        {
            ExplorerTree,
            FavouritesTree
        }
    }

}
 
